#!/usr/bin/env python3
# -*-coding : utf-8 -*-
# @time     : 2019/9/22 0022 下午 6:13
# @Author   : Administrator
# @FileName : 国家药监局化妆品生产许可信息.py
# --------------------------------------------------------

"""
描述信息
"""

import requests

url = "http://125.35.6.84:81/xk/"
# 所有的数据信息
xk_list_url = "http://125.35.6.84:81/xk/itownet/portalAction.do?method=getXkzsList"
detail_url = "http://125.35.6.84:81/xk/itownet/portalAction.do?method=getXkzsById"
# UA伪装
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0"
}
# 前10页数据
for page in range(1, 11):
    data = {
        "on": "true",
        "page": page,
        "pageSize": "15",
        "productName": "",
        "conditionType": "1",
        "applyname": "",
        "applysn": "",
    }
    response = requests.post(url=xk_list_url, data=data, headers=headers)
    # response.headers返回的是响应头信息
    if response.headers['Content-Type'] == "application/json;charset=UTF-8":
        response.encoding = 'utf8'
        obj_json = response.json()
        # print(obj_json)
        for item in obj_json['list']:
            name = item["EPS_NAME"]
            _id = item['ID']
            print("公司ID：", _id, "公司名称:", name)
            # 查询详细信息
            detail_data = {
                "id": _id
            }
            response = requests.post(url=detail_url, data=detail_data, headers=headers)
            response.encoding = "utf8"
            obj_json = response.json()
            print("详细信息:", obj_json)
